package com.example.demo1.mapper;

import com.example.demo1.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper {

    @Select("select * from user where name = #{name}")
    public User findByName(String name);

    @Insert("insert into user(name,password,create_time,update_time)"+
            "values(#{name},#{password},now(),now())")
    void add(String name, String password);

    @Update("update user set nickname=#{nickname},email=#{email},update_time=#{updateTime} where id=#{id}")
    void update(User user);

//    @Update("update user set user_pic=#{avatarUrl},update_time=now() where id=#{id}")
//    void updateAvatar(String avatarUrl, Integer id);user_pic

    @Update("update user set password=#{newPwd},update_time=now() where id=#{id}")
    void updatePwd(String newPwd, Integer id);

    //查找照片
    @Select("select user_pic from user where id = #{id}")
    String uploadSelect(Integer id);

    @Update("update user set user_pic = #{userPic} where id = #{id}")
    void upload(String userPic, Integer id);
}


